package com.qqtech.qquan.draw.service;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.qqtech.core.common.util.TimeUtil;
import com.qqtech.core.frame.dao.BaseDao;
import com.qqtech.core.frame.service.BaseServiceImpl;
import com.qqtech.qquan.draw.dao.DrawBaseDao;
import com.qqtech.qquan.draw.enums.DrawConst;
import com.qqtech.qquan.draw.model.DrawBase;
import com.qqtech.qquan.draw.model.DrawSysParam;
import com.qqtech.qquan.user.service.UserDrawService;

@Service
public class DrawBaseServiceImpl extends BaseServiceImpl<DrawBase> implements DrawBaseService {
	public static final Logger log = LoggerFactory.getLogger(DrawBaseServiceImpl.class);

	@Resource
	private DrawBaseDao drawBaseDao;

	@Resource
	private UserDrawService userDrawService;

	@Resource
	private DrawSysParamService drawSysParamService;

	@Override
	protected BaseDao<DrawBase> getBaseDao() {
		return drawBaseDao;
	}

	@Override
	public String getDrawHours() {
		String chooseHours = null;
		DrawSysParam drawSysParamVo2 = drawSysParamService.getByKey(DrawConst.PARAMKEY_DRAW_HOUR);// 双旦小时时间段
		String[] hours = drawSysParamVo2.getValue().split(",");
		int nowHour = TimeUtil.now().getHours();
		for (String hour : hours) {
			String[] hourNumber = hour.split("-");
			if (nowHour >= Integer.valueOf(hourNumber[0]) && nowHour < Integer.valueOf(hourNumber[1])) {// 当前小时在12-14,16-18,20-22,0-2之间
				chooseHours = hour;
				break;
			}
		}
		return chooseHours;
	}
}